import { ElNotification, ElMessageBox } from "element-plus";
import nprogress from 'nprogress'

export function successMsg(message,dangerouslyUseHTMLString = false){
  ElNotification({
    message: message,
    type: 'success',
    duration: 2000
  });
}

export function errorMsg(message,dangerouslyUseHTMLString = false){
  ElNotification({
    message,
    type: 'error',
    duration: 2000,
    dangerouslyUseHTMLString
  });
}

export function modalMsg(content = '提示内容', type = 'info', title = ""){
  return ElMessageBox.confirm(
    content,title,{
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type
    }
  )
}

// 点击确认后返回给调用方的数据：{value: '1114.jpg', action: 'confirm'}
export function showPrompt(tip, value = ''){
  return ElMessageBox.prompt(tip, '', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    inputValue: value
  })
}

export function showGlobalProgress(){
  nprogress.start()
}

export function doneGlobalProgress(){
  nprogress.done()
}
